package com.lizhen.core.datastructure;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class HashMapDataStructure {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("1", "value1");
        map.put("2", "value2");
        map.put("3", "value3");
        Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();

        for (String str : map.keySet()) {
            System.out.println("key=" + str + " and value=" + map.get(str));
        }

        while (iterator.hasNext()) {
            Map.Entry<String, String> entry = iterator.next();

            System.out.println("key=" + entry.getKey() + " and value=" + entry.getValue());
        }

        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println("key=" + entry.getKey() + " and value=" + entry.getValue());
        }

        for (String str : map.values()) {
            System.out.println("value=" + str);
        }
    }
}
